package com.zk.springboot.modules.log;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import com.zk.springboot.interfaces.common.IWebFrame;
import com.zk.springboot.interfaces.common.IWebModule;
import com.zk.springboot.interfaces.common.IWebService;
import com.zk.springboot.interfaces.common.log.ISysLogService;
import com.zk.springboot.interfaces.common.log.IUserLogService;
@Service("logService")
public class ServiceModule implements IWebModule{
	public static final String MODULE_NAME="log";
	public static ServiceModule instance = new ServiceModule();
	List<IWebService> services=new ArrayList<IWebService>();

	private IUserLogService userLogService;
	private ISysLogService sysLogService;
	ApplicationContext context;
	
	
	public void initModule(ApplicationContext context,IWebFrame frame){
		instance.frame=frame;
		instance.context=context;
		instance.userLogService=context.getBean(IUserLogService.class);
		instance.services.add(instance.userLogService);
		instance.sysLogService=context.getBean(ISysLogService.class);
		instance.services.add(instance.sysLogService);
	}

	@Override
	public List<IWebService> getServiceList() {
		return instance.services;
	}

	@Override
	public <T> T getService(Class<T> requiredType) {
		return instance.context.getBean(requiredType);
	}

	private IWebFrame frame;

	public IWebFrame getFrame() {
		return instance.frame;
	}

	@Override
	public String appId() {
		return MODULE_NAME;
	}
	}